package mz.behaveas.runner {
	import mz.behaveas.model.spec.SpecRunListener;
	import mz.behaveas.model.spec.SpecificationFactory;
	import mz.behaveas.model.spec.Specification;
	
	/**
	 * This is a simple Runner implementation. 
	 * 
	 * @author maxim.zaks@gmail.com
	 */
	public class SimpleModelRunner{
		
		
		public static function checkSpecificationsWithSOSReport(... specs) : void {
			var reporter : SpecRunListener = new SOSMaxReporter();
			var startTime : Number = new Date().time;
			reporter.startReport(specs.length);
			var specIndex : int = 1;
			var notCorrectExpectations : int = 0;
			var numberOfExpectations : int = 0;
			for each (var spec : * in specs) {
				var actSpec : Specification = SpecificationFactory.createSpec(spec);
				reporter.runSpec(actSpec.description, specIndex);
				actSpec.runExpectations(reporter);
				reporter.specReport(actSpec.report);
				notCorrectExpectations += actSpec.numberOfNotCorrectExpectations;
				numberOfExpectations += actSpec.numberOfExpectations;
				specIndex++;
			}
			reporter.endReport(numberOfExpectations, notCorrectExpectations, (new Date().time - startTime));
		}

	}
}
